<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The RecursiveArrayIterator class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="parentiterator.rewind.html">« ParentIterator::rewind</a></li>
      <li style="float: right;"><a href="recursivearrayiterator.getchildren.html">RecursiveArrayIterator::getChildren »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="spl.iterators.html">迭代器</a></li>
    <li>The RecursiveArrayIterator class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.recursivearrayiterator" class="reference">
 <h1 class="title">The RecursiveArrayIterator class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p>


  <div class="section" id="recursivearrayiterator.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    This iterator allows to unset and modify values and keys while iterating over Arrays and Objects
    in the same way as the <span class="type"><a href="class.arrayiterator.html" class="type ArrayIterator">ArrayIterator</a></span>. Additionally it is possible to iterate
    over the current iterator entry.
   </p>
  </div>


  <div class="section" id="recursivearrayiterator.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">RecursiveArrayIterator</strong>
     </span>

     <span class="ooclass">
      <span class="modifier">extends</span>
       <a href="class.arrayiterator.html" class="classname">ArrayIterator</a>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.recursiveiterator.html" class="interfacename">RecursiveIterator</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.arrayiterator.html#arrayiterator.constants.std-prop-list"><var class="varname">ArrayIterator::STD_PROP_LIST</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.arrayiterator.html#arrayiterator.constants.array-as-props"><var class="varname">ArrayIterator::ARRAY_AS_PROPS</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.recursivearrayiterator.html#recursivearrayiterator.constants.child-arrays-only"><var class="varname">CHILD_ARRAYS_ONLY</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="recursivearrayiterator.getchildren.html" class="methodname">getChildren</a></span>(): <span class="type"><span class="type">?</span><span class="type"><a href="class.recursivearrayiterator.html" class="type RecursiveArrayIterator">RecursiveArrayIterator</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="recursivearrayiterator.haschildren.html" class="methodname">hasChildren</a></span>(): <span class="type">bool</span></div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.append.html" class="methodname">ArrayIterator::append</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.asort.html" class="methodname">ArrayIterator::asort</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code>SORT_REGULAR</code></strong></span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.count.html" class="methodname">ArrayIterator::count</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.current.html" class="methodname">ArrayIterator::current</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.getarraycopy.html" class="methodname">ArrayIterator::getArrayCopy</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.getflags.html" class="methodname">ArrayIterator::getFlags</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.key.html" class="methodname">ArrayIterator::key</a></span>(): <span class="type"><span class="type">string</span>|<span class="type">int</span>|<span class="type">null</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.ksort.html" class="methodname">ArrayIterator::ksort</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code>SORT_REGULAR</code></strong></span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.natcasesort.html" class="methodname">ArrayIterator::natcasesort</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.natsort.html" class="methodname">ArrayIterator::natsort</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.next.html" class="methodname">ArrayIterator::next</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.offsetexists.html" class="methodname">ArrayIterator::offsetExists</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.offsetget.html" class="methodname">ArrayIterator::offsetGet</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.offsetset.html" class="methodname">ArrayIterator::offsetSet</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.offsetunset.html" class="methodname">ArrayIterator::offsetUnset</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$key</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.rewind.html" class="methodname">ArrayIterator::rewind</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.seek.html" class="methodname">ArrayIterator::seek</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.serialize.html" class="methodname">ArrayIterator::serialize</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.setflags.html" class="methodname">ArrayIterator::setFlags</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.uasort.html" class="methodname">ArrayIterator::uasort</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.uksort.html" class="methodname">ArrayIterator::uksort</a></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.unserialize.html" class="methodname">ArrayIterator::unserialize</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="arrayiterator.valid.html" class="methodname">ArrayIterator::valid</a></span>(): <span class="type">bool</span></div>

   }</div>

  </div>

  <div class="section" id="recursivearrayiterator.constants">
   <h2 class="title">预定义常量</h2>
   <div class="section" id="recursivearrayiterator.constants.flags">
    <h2 class="title">RecursiveArrayIterator Flags</h2>
    <dl>
     
      <dt id="recursivearrayiterator.constants.child-arrays-only"><strong><code>RecursiveArrayIterator::CHILD_ARRAYS_ONLY</code></strong></dt>

      <dd>

       <p class="para">Treat only arrays (not objects) as having children for recursive iteration.</p>
      </dd>

     
    </dl>

   </div>
  </div>



 </div>

 












<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="recursivearrayiterator.getchildren.html">RecursiveArrayIterator::getChildren</a> — Returns an iterator for the current entry if it is an array or an object</li><li><a href="recursivearrayiterator.haschildren.html">RecursiveArrayIterator::hasChildren</a> — Returns whether current entry is an array or an object</li></ul>
</div>
</div></div></body></html>